<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计划时间修改</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/show/css/font.css">
    <link rel="stylesheet" href="/show/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/show/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/show/js/xadmin.js"></script>
</head>
<body>
<div class="x-body">
    <form class="layui-form">
        <input type="hidden" name="planItem" id="planItem" th:value="${pars.planItem}">
        <div th:each="par:${pars.parList}">
            <input type="hidden" name="activityId" th:value="${par.activity.activityId}">
            <div class="layui-form-item">
                <label  class="layui-form-label">
                    节目名
                </label>
                <div class="layui-input-inline">
                    <input type="text"  name="activityName"  readonly="readonly"
                           autocomplete="off" class="layui-input" placeholder="表演节目名" th:value="${par.activity.activityName}">
                </div>
                <p id="message"></p>
            </div>

            <div class="layui-form-item">
                <label  class="layui-form-label">
                    工作日演出时间
                </label>
                <div class="layui-input-inline">
                    <input type="text"  name="showWorkdayTime"
                           autocomplete="off" class="layui-input" placeholder="工作日演出时间" th:value="${par.showWorkdayTime}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">
                    周末演出时间
                </label>
                <div class="layui-input-inline">
                    <input type="text"  name="showWeekdayTime"
                           autocomplete="off" class="layui-input" placeholder="周末演出时间" th:value="${par.showWeekdayTime}">
                </div>
            </div>


            <div class="layui-form-item" style="width: 500px">
                <label class="layui-form-label">停演时间</label>
                <div class="layui-input-line" >
                    <!-- 所属区域下拉隐藏值-->
                    <select style="width: 300px" name="showStopWeekday" id="showStopWeekday" layui-select="">
                        <option th:if="${par.showStopWeekday eq '周一'}"  value="周一" selected>周一</option>
                        <option th:if="${par.showStopWeekday ne '周一'}"  value="周一" >周一</option>

                        <option th:if="${par.showStopWeekday eq '周二'}"  value="周二" selected>周二</option>
                        <option th:if="${par.showStopWeekday ne '周二'}"  value="周二" >周二</option>

                        <option th:if="${par.showStopWeekday eq '周三'}"  value="周三" selected>周三</option>
                        <option th:if="${par.showStopWeekday ne '周三'}"  value="周三" >周三</option>

                        <option th:if="${par.showStopWeekday eq '周四'}"  value="周四" selected>周四</option>
                        <option th:if="${par.showStopWeekday ne '周四'}"  value="周四" >周四</option>

                        <option th:if="${par.showStopWeekday eq '周五'}"  value="周五" selected>周五</option>
                        <option th:if="${par.showStopWeekday ne '周五'}"  value="周五" >周五</option>

                        <option th:if="${par.showStopWeekday eq '周六'}"  value="周六" selected>周六</option>
                        <option th:if="${par.showStopWeekday ne '周六'}"  value="周六" >周六</option>

                        <option th:if="${par.showStopWeekday eq '周日'}"  value="周日" selected>周日</option>
                        <option th:if="${par.showStopWeekday ne '周日'}"  value="周日" >周日</option>

                        <option th:if="${par.showStopWeekday eq 'null'}"  value="null" selected>无</option>
                        <option th:if="${par.showStopWeekday ne 'null'}"  value="null" >无</option>
                    </select>
                </div>
            </div>
            <hr>
        </div>
            <div class="layui-form-item">
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    保存
                </button>
                <br><br><br><br><br><br>
            </div>
    </form>
</div>
</body>
<script>
    //form表单,layer弹出框
    layui.use(['form','layer'],function () {
        $ = layui.jquery;
        var form = layui.form, layer = layui.layer;

        //确认按钮
        form.on('submit(add)', function (data) {
            var activityId="";
            var showWorkdayTime="";
            var showWeekdayTime="";
            var showStopWeekday="";
            var planItem = document.getElementById("planItem").value;
            for(var i=0;i<document.getElementsByName("activityId").length;i++){
                activityId += document.getElementsByName("activityId")[i].value + ",";
            }
            for(var i=0;i<document.getElementsByName("showWorkdayTime").length;i++){
                if (document.getElementsByName("showWeekdayTime")[i].value==""){
                    showWorkdayTime += "null"+",";
                }else {
                    showWorkdayTime += document.getElementsByName("showWorkdayTime")[i].value + ",";
                }
            }
            for(var i=0;i<document.getElementsByName("showWeekdayTime").length;i++){
                if (document.getElementsByName("showWeekdayTime")[i].value==""){
                    showWeekdayTime += "null"+",";
                }else {
                    showWeekdayTime += document.getElementsByName("showWeekdayTime")[i].value + ",";
                }
            }
            for(var i=0;i<document.getElementsByName("showStopWeekday").length;i++){
                showStopWeekday += document.getElementsByName("showStopWeekday")[i].value + ",";
            }

            $.ajax({
                url: "/plan/updatePlan",
                async: false,
                type: "POST",
                dataType: "json",
                data: {
                    "activityId":activityId,
                    "showWorkdayTime":showWorkdayTime,
                    "showWeekdayTime":showWeekdayTime,
                    "showStopWeekday":showStopWeekday,
                    "planItem":planItem
                },
                success: function (data) {
                    //提示信息
                    layer.alert(data.info);
                    //放入了map中，调用info
                    if (data.info == "success") {
                        //获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        //刷新
                        parent.window.location.replace("/plan/planList")
                    }else{
                        layer.msg(data.info,{icon: 5,time:1000});
                    }
                }

            })

        })
    })

</script>

</html>
